package com.forclass;

import java.lang.reflect.InvocationTargetException;

public class Factory1 {
    private Factory1() {

    }
    public static IBook1920 getInstance(String className) {
        Object obj = null;
        try {
            obj = Class.forName(className).getDeclaredConstructor().newInstance();
            if (obj instanceof IBook1920) {
                return (IBook1920) obj;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
